# 使用Git绝对路径
$gitPath = "C:\Program Files\Git\bin\git.exe"

# 验证Git安装
try {
    & $gitPath --version
    Write-Host "Git is installed correctly."
} catch {
    Write-Host "Git is not installed correctly."
    pause
    exit 1
}

# 配置Git用户信息
& $gitPath config --global user.name "yuzh0618"
& $gitPath config --global user.email "yuzh0618@126.com"

# 初始化Git仓库
& $gitPath init

# 添加远程仓库
& $gitPath remote add origin https://gitee.com/yuzh0618/mess-mcp.git

# 添加所有文件
& $gitPath add .

# 提交代码
& $gitPath commit -m "Initial commit"

# 推送代码到远程仓库
try {
    & $gitPath push -u origin master
    Write-Host "Code pushed successfully!"
} catch {
    Write-Host "Failed to push code. Check network connection and Gitee credentials."
}

pause